﻿using System;

namespace WebBridge.Proxy
{
    class XSEngineConnection : IXSEngineConnection
    {
        private static volatile XSEngineConnection _instance;
        private static readonly object _mutex = new object();

        private XSEngineConnection()
        {
        }

        public static XSEngineConnection Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (_mutex)
                    {
                        if (_instance == null)
                        {
                            _instance = new XSEngineConnection();
                        }
                    }
                }
                return _instance;
            }
        }

        public void Login(string spHost, string idpCookie)
        {
            Console.WriteLine("XS::Login, host={0}, cookie={1}", spHost, idpCookie);
        }

        public string RetrieveXAppList()
        {
            Console.WriteLine("XS::RetrieveXAppList");
            return "[{name:'sap'},{name:'my'}]";
        }
    }

    interface IXSEngineConnection
    {
        void Login(string spHost, string idpCookie);
        string RetrieveXAppList();
    }
}
